package ylsb.service;


import org.springframework.stereotype.Service;
import ylsb.dao.YltpBaofeiMapper;
import ylsb.model.YltpBaofei;
import ylsb.model.YltpBaofeiExample;


import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class YltpbaofeiService {
    @Resource
    YltpBaofeiMapper ddMapper;
    public List<YltpBaofei> findBaofeilist(String xiangmuId){
        YltpBaofeiExample mmExample=new YltpBaofeiExample();
        mmExample.createCriteria().andXiangmuidEqualTo(xiangmuId);
        mmExample.setOrderByClause("ordernumber ASC");
        return  ddMapper.selectByExample(mmExample);
    }
    public List<Map<String, Object>> findByXiangmuId(String mmxiangmuId){

        return ddMapper.findByXiangmuId(mmxiangmuId);
    }
    public boolean add(YltpBaofei ppYltpBaofei){
        return ddMapper.insert(ppYltpBaofei)==1;
    }
    public boolean isexistByxiangmuId(String xiangmuId){
        YltpBaofeiExample mmExample=new YltpBaofeiExample();
        YltpBaofeiExample.Criteria criteria=mmExample.createCriteria();
        criteria.andXiangmuidEqualTo(xiangmuId);
        return  ddMapper.selectByExample(mmExample).size()>0;
    }
    public boolean deleteByxiangmuId(String xiangmuId){
        YltpBaofeiExample mmExample=new YltpBaofeiExample();
        YltpBaofeiExample.Criteria criteria=mmExample.createCriteria();
        criteria.andXiangmuidEqualTo(xiangmuId);
        return  ddMapper.deleteByExample(mmExample)>=0;
    }

    public List<Map<String, Object>> findBiaojuelist(String mmxiangmuId, String mmuserId){

        return ddMapper.findBiaojuelist(mmxiangmuId,mmuserId);
    }
    public Integer getVoteCount(String ppxiangmuId){
        List<Map<String, Object>> list=ddMapper.findByXiangmuId(ppxiangmuId);
        return list == null ? 0 : list.size();
    }

}
